﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Find third bit</title>
</head>
<body>
    <label for="textIn">Enter number: </label>
    <input id="textIn" type="text" name="name" value=" " />
    <label for="textOut">Third bit is:</label>
    <input id="textOut" type="text" name="name" value=" " />
    <input type="button" name="name" value="GO" onclick="FindThirdBit()" />

    <script>
        function FindThirdBit() {
            var number = parseInt(document.getElementById("textIn").value);
            var mask = 1 << 3;
            var numberAndMask = number & mask;
            numberAndMask = numberAndMask >> 3;
            document.getElementById("textOut").value = numberAndMask;
        }
    </script>
</body>
</html>
